﻿using System;
using fastCSharp.code.cSharp;
using fastCSharp;

namespace diantou.web.ajax.api
{
    /// <summary>
    /// OJ测试操作
    /// </summary>
    [fastCSharp.code.cSharp.ajax(IsPool = true)]
    class judge : jsonHandle<judge>
    {
        /// <summary>
        /// 外部提交
        /// </summary>
        /// <param name="token"></param>
        /// <param name="judge"></param>
        /// <param name="onReturn"></param>
        [fastCSharp.code.cSharp.ajax(IsReferer = false)]
        public void Open(string token, diantou.dataAccess.judge judge, Action<fastCSharp.net.returnValue<fastCSharp.openApi._51nod.returnValue.value>> onReturn)
        {
            if (token == null || judge == null) onReturn(default(fastCSharp.openApi._51nod.returnValue.value));
            else diantou.dataAccess.tcpCall.openJudge.append(token, judge, onReturn);
        }
        /// <summary>
        /// 外部批量提交
        /// </summary>
        /// <param name="token"></param>
        /// <param name="judges"></param>
        /// <param name="onReturn"></param>
        [fastCSharp.code.cSharp.ajax(IsReferer = false, MaxPostDataSize = 4)]
        public void Batch(string token, diantou.dataAccess.judge[] judges, Action<fastCSharp.net.returnValue<fastCSharp.openApi._51nod.returnValue<int[]>.value>> onReturn)
        {
            if (token == null || judges.length() == 0) onReturn(default(fastCSharp.openApi._51nod.returnValue<int[]>.value));
            else diantou.dataAccess.tcpCall.openJudge.append(token, judges, onReturn);
        }
        /// <summary>
        /// 外部提交回调测试
        /// </summary>
        [fastCSharp.code.cSharp.ajax(IsReferer = false)]
        public bool Callback(fastCSharp.openApi._51nod.callbackType Type, diantou.dataAccess.openJudge.judgeResult[] Value)
        {
            log.Default.Add(Type.ToString() + " " + Value.ToJson(), new System.Diagnostics.StackFrame(), false);
            return true;
        }
    }
}
